var express = require('express');
var router = express.Router();
const {
  addTypes,
  delTypesById,
  getTypes,
  getAllTypes,
  changeTypesById,
  getTypesById
} = require("../service/typesService")

/* GET home page. */
// 新增保险分类
router.post('/addTypes', async function (req, res, next) {
  const data = await addTypes(req.body)
  res.send(data)
});

// 获取保险分类
// router.post('/getTypes', async function (req, res, next) {
//   const data = await getTypes()
//   res.send(data)
// });


// 获取所有保险分类
router.get('/getAllTypes', async function (req, res, next) {
  const data = await getAllTypes()
  res.send(data)
});


// 删除保险分类
router.post('/delTypesById', async function (req, res, next) {
  const data = await delTypesById(req.body);
  res.send(data)
});

router.get('/getTypesById', async function (req, res, next) {
  const data = await getTypesById(req.query)
  res.send(data)
});


router.post('/changeTypesById', async function (req, res, next) {
  const data = await changeTypesById(req.body);
  console.log(req.body);
  res.send(data)
});
module.exports = router;